#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

int n;
int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--){
        cin >> n;
        if((n - 2) % 2){
            cout << "1 2 3 ";
            for(int i = n - 2; i >= 4; i --) cout << i << " ";
            cout << n - 1 << " " << n;
            cout << '\n';
        }else{
            for(int i = n - 2; i >= 1; i --){
                cout << i << " ";
            }
            cout << n - 1 << " " << n;
            cout << '\n';
        }
    }

    return 0;
}